package 字符串算法.回文串;

public class 验证回文串 {
    public boolean isPalindrome(String s){
        if (s.length()==0){
            return true;
        }
        int l = 0; int r = s.length() - 1;
        while(l<r){
           //判断字符不是字母数字的情况
            if (!Character.isLetterOrDigit(s.charAt(l))){
                l++;
            }
            if (!Character.isLetterOrDigit(s.charAt(r))){
                r--;
            }else {
                if (Character.toLowerCase(s.charAt(l))!=Character.toLowerCase(s.charAt(r))){
                    return false;
                }
                l++;
                r++;
            }


        }
        return true;
    }
}
